package oop.encapsulation;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * ClassName: EmployeeTest
 * Package: oop.encapsulation
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-11-20
 * Time: 11:29
 */

public class EmployeeTest {
    public static void main(String[] args) {

        //创建 employee数组
        Employee[] emps = new Employee[2];

        Scanner scanner = new Scanner(System.in);
        for (int i = 0; i < emps.length; i++) {
            emps[i] = new Employee();

            System.out.println("----------添加第" + (i + 1) + "个员工----------");
            System.out.println("姓名: ");
            String name = scanner.next();
            System.out.println("性别: ");
            char gender = scanner.next().charAt(0);
            System.out.println("年龄: ");
            int age = scanner.nextInt() ;
            System.out.println("电话: ");
            String phone = scanner.next();

            //给指定属性赋值
            emps[i].setName(name);
            emps[i].setAge(age);
            emps[i].setGender(gender);
            emps[i].setPhoneNumber(phone);

        }

        //遍历员工列表
        System.out.println("-------员工列表----------");
        System.out.println("编号\t姓名\t性别\t年龄\t电话");
        for (int i = 0; i < emps.length; i++) {
            System.out.println((i+1) + "\t" + emps[i].getInfo());
        }


    }
}
